package com.ruoyi.user.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.user.domain.AppointmentList;
import com.ruoyi.user.service.IAppointmentListService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 预约列表Controller
 * 
 * @author ruoyi
 * @date 2025-09-11
 */
@RestController
@RequestMapping("/appointment")
public class AppointmentListController extends BaseController
{
    @Autowired
    private IAppointmentListService appointmentListService;

    /**
     * 查询预约列表列表
     */
    @RequiresPermissions("user:appointment:list")
    @GetMapping("/list")
    public TableDataInfo list(AppointmentList appointmentList)
    {
        startPage();
        List<AppointmentList> list = appointmentListService.selectAppointmentListList(appointmentList);
        return getDataTable(list);
    }

    /**
     * 导出预约列表列表
     */
    @RequiresPermissions("user:appointment:export")
    @Log(title = "预约列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppointmentList appointmentList)
    {
        List<AppointmentList> list = appointmentListService.selectAppointmentListList(appointmentList);
        ExcelUtil<AppointmentList> util = new ExcelUtil<AppointmentList>(AppointmentList.class);
        util.exportExcel(response, list, "预约列表数据");
    }

    /**
     * 获取预约列表详细信息
     */
    @RequiresPermissions("user:appointment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(appointmentListService.selectAppointmentListById(id));
    }

    /**
     * 新增预约列表
     */
    @RequiresPermissions("user:appointment:add")
    @Log(title = "预约列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppointmentList appointmentList)
    {
        return toAjax(appointmentListService.insertAppointmentList(appointmentList));
    }

    /**
     * 修改预约列表
     */
    @RequiresPermissions("user:appointment:edit")
    @Log(title = "预约列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppointmentList appointmentList)
    {
        return toAjax(appointmentListService.updateAppointmentList(appointmentList));
    }

    /**
     * 删除预约列表
     */
    @RequiresPermissions("user:appointment:remove")
    @Log(title = "预约列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(appointmentListService.deleteAppointmentListByIds(ids));
    }
}
